home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST7-16.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  49 lines

  1. ;
  2. ; *** Listing 7-16 ***
  3. ;
  4. ; Performs fast, compact bit-doubling of a byte in AL
  5. ; to a word in AX by using two nibble look-ups rather
  6. ; than a byte look-up.
  7. ;
  8. ; Macro to double each bit in a byte.
  9. ;
  10. ; Input:
  11. ;    AL = byte to bit-double
  12. ;
  13. ; Output:
  14. ;    AX = bit-doubled word
  15. ;
  16. ; Registers altered: AX, BX, CL
  17. ;
  18. DOUBLE_BYTE    macro
  19.     mov    bl,al    ;move the byte to look up to BL
  20.     sub    bh,bh    ; and make a word out of the value
  21.     mov    cl,4    ;make a look-up pointer out of the
  22.     shr    bx,cl    ; upper nibble of the byte
  23.     mov    ah,[DoubledNibbleTable+bx]
  24.             ;look up the doubled upper nibble
  25.     mov    bl,al    ;get the byte to look up again,
  26.     and    bl,0fh    ; and make a pointer out of the
  27.             ; lower nibble this time
  28.     mov    al,[DoubledNibbleTable+bx]
  29.             ;look up the doubled lower nibble
  30.     endm
  31. ;
  32.     jmp    Skip
  33. DOUBLED_VALUE=0
  34. DoubledNibbleTable    label    byte
  35.     db    000h, 003h, 00ch, 00fh
  36.     db    030h, 033h, 03ch, 03fh
  37.     db    0c0h, 0c3h, 0cch, 0cfh
  38.     db    0f0h, 0f3h, 0fch, 0ffh
  39. ;
  40. Skip:
  41.     call    ZTimerOn
  42. BYTE_TO_DOUBLE=0
  43.     rept    100
  44.     mov    al,BYTE_TO_DOUBLE
  45.     DOUBLE_BYTE
  46. BYTE_TO_DOUBLE=BYTE_TO_DOUBLE+1
  47.     endm
  48.     call    ZTimerOff
  49.